/*=+--+=#=+--     Unmanned Aerial System Management Software      --+=#=+--+=#*\
|          Copyright (C) 2011 Regents of the University of Colorado.           |
|                             All Rights Reserved.                             |

     This program is free software: you can redistribute it and/or modify
     it under the terms of the GNU General Public License version 2 as
     published by the Free Software Foundation.

     This program is distributed in the hope that it will be useful,
     but WITHOUT ANY WARRANTY; without even the implied warranty of
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     GNU General Public License for more details.

     You should have received a copy of the GNU General Public License
     along with this program.  If not, see <http://www.gnu.org/licenses/>.

            Jack Elston                       Cory Dixon                        
|           elstonj@colorado.edu              dixonc@colorado.edu              |
|                                                                              |
\*=+--+=#=+--                 --+=#=+--+=#=+--                    --+=#=+--+=#*/

/*!
	\file nodePages.h
	\author Cory Dixon
*/

#ifndef __NODE_PAGE_H
#define __NODE_PAGE_H

#include <gtk/gtk.h>
#include "clientList.h"

//--- base page class
class NodePage
{
	public:
		NodePage() {page = NULL;}
		virtual ~NodePage() {page = NULL; page_client=NULL; }
		
		//-- page update --//
		//  redefine this function to setup the page with its callbacks
		//  and to associate xml with class names.
		virtual void update() = 0;

		//-- page creation --//
		//  redefine this function to setup the page with its callbacks
		//  and to associate xml with class names.
		virtual bool create_page(Client *client, GtkBuilder *builder) = 0;

		// use this function to indicate a command or ACK has been received
		virtual void setCMD_RX(uint8_t cmd_id, int ack_nack=-1) { return; }

		void set_sent_state(GtkWidget *button) {
			GdkColor yellow; gdk_color_parse ("yellow", &yellow);
			gtk_widget_modify_bg( button, GTK_STATE_NORMAL, &yellow);
			gtk_widget_modify_bg( button, GTK_STATE_SELECTED, &yellow);
			gtk_widget_modify_bg( button, GTK_STATE_ACTIVE, &yellow);
			gtk_widget_modify_bg( button, GTK_STATE_PRELIGHT, &yellow);
		}
		void set_rx_state(GtkWidget *button, int ack_nack) {
			if( ack_nack == 1 ) {
				gtk_widget_modify_bg( button, GTK_STATE_NORMAL, NULL);
				gtk_widget_modify_bg( button, GTK_STATE_SELECTED, NULL);
				gtk_widget_modify_bg( button, GTK_STATE_ACTIVE, NULL);
				gtk_widget_modify_bg( button, GTK_STATE_PRELIGHT, NULL);
			} else if( ack_nack == 0 ) {
				GdkColor red; gdk_color_parse ("red", &red);
				gtk_widget_modify_bg( button, GTK_STATE_NORMAL, &red);
				gtk_widget_modify_bg( button, GTK_STATE_SELECTED, &red);
				gtk_widget_modify_bg( button, GTK_STATE_ACTIVE, &red);
				gtk_widget_modify_bg( button, GTK_STATE_PRELIGHT, &red);
			}
		}
		void set_bad_state(GtkWidget *button) {
			GdkColor red; gdk_color_parse ("red", &red);
			gtk_widget_modify_bg( button, GTK_STATE_NORMAL, &red);
			gtk_widget_modify_bg( button, GTK_STATE_SELECTED, &red);
			gtk_widget_modify_bg( button, GTK_STATE_ACTIVE, &red);
			gtk_widget_modify_bg( button, GTK_STATE_PRELIGHT, &red);
		}
		void set_good_state(GtkWidget *button) {
			GdkColor green; gdk_color_parse ("green", &green);
			gtk_widget_modify_bg( button, GTK_STATE_NORMAL, &green);
			gtk_widget_modify_bg( button, GTK_STATE_SELECTED, &green);
			gtk_widget_modify_bg( button, GTK_STATE_ACTIVE, &green);
			gtk_widget_modify_bg( button, GTK_STATE_PRELIGHT, &green);
		}

	protected:
		//--------------------PAGE VARIABLES--------------------//
		GtkWidget * page;  // this is your gtk page in the note, techically
		                   // can be placed into any container

		Client    * page_client;

		//-- display --//
		//   in this section, add the names of the widgets you designed
		//   in glade for the page you are creating
		
		//-- input entry --//
		//  in this section, add any input boxes you gave to the user
		//  for input selection, can be buttons, text input, check boxes, ...

		//-- callbacks --//
		//  in this section, add any of the callbacks you need to handle
		//  user input. Note, more than likely these will need to be static functions.
		//  Also, for the pointer we pass the WindowStruct pointer, which provides
		//  all the inormatio necessary to dray any/all pages
};

#endif
